<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{webjars/jquery/3.2.1/dist/jquery.min.js}"></script>
    <script>
        $(function () {
            $(".delete").click(function () {
                $("#ff").attr("action",this.href).submit();
                return false;
            });
        });
    </script>
    <style>
        h1{
            text-align: center;
        }
        table{
            border-collapse: collapse;
            width: 600px;
            margin: 0 auto;
        }
        td,th{
            border: 1px solid black;
            line-height: 35px;
            text-align: center;
        }
        tr:nth-child(odd){
            background-color: sienna;
        }
        p{
            width: 600px;
            text-align: right;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <h1>员工列表</h1>
    <p>
        <a th:href="@{/emps/view}">新增</a>
    </p>
    <table>
        <tr>
        <th>员工编号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
        <th>工资</th>
        <th>生日</th>
        <th>职位</th>
        <th>操作</th>
        </tr>
        <tr th:each="emp:${list}">
            <td th:text="${emp.id}"></td>
            <td th:text="${emp.name}"></td>
            <td th:text="${emp.sex}"></td>
            <td th:text="${emp.age}"></td>
            <td th:text="${emp.sal}"></td>
            <td th:text="${#calendars.format(emp.birthday,'yyyy-MM-dd')}"></td>
            <td th:text="${emp.jobDesc}"></td>
            <td>
                <a th:href="@{'/emps/'+${emp.id}}">修改</a>
                |
                <a class="delete" th:href="@{'/emps/'+${emp.id}}">删除</a>
            </td>
        </tr>
    </table>
    <form id="ff" method="post">
        <input type="hidden" name="_method" value="DELETE">
    </form>

</body>
</html>